package com.wzx.controller;

import com.wzx.domain.MyQueryOv;
import com.wzx.domain.MyQueryOv2;
import com.wzx.domain.Person;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Controller
public class Demo01Controller {
    @RequestMapping("delete1.action")
    public ModelAndView test01(Integer[] ids){//参数只需要写数组
        System.out.println(Arrays.toString(ids));
        return null;
    }
    @RequestMapping("delete2.action")
    public ModelAndView test02(MyQueryOv ov){//参数只需要写QueryOV类
        System.out.println(Arrays.toString(ov.getIds()));
        return null;
    }

    @RequestMapping(path = "updateUI.action",method = {RequestMethod.POST,RequestMethod.GET})//回显页面
    public ModelAndView test04(){//
        Person p1 = new Person(1,"jack","1234");
        Person p2 = new Person(2,"rose","1234");
        List<Person> list = new ArrayList<Person>();
        list.add(p1);
        list.add(p2);

        //使用ModelAndView实现请求转发
        ModelAndView mv = new ModelAndView();
        mv.addObject("list",list);
        mv.setViewName("demo04_update_persons");
        return mv;
    }
    @RequestMapping("update3.action")
    public ModelAndView test03(MyQueryOv2 ov){//参数写QueryOv2类，但是页面要指定变量名与索引
        System.out.println(ov.getList());
        return null;
    }
}
